#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Script to generate a reduced image thanks to the right-click 'Open with' menu. (You need to set this manually).
#
#
# @author Jean-Baptiste Fiot <hellwoxx@gmail.com>
# @version Jan 2011


import sys, os, subprocess

def main():
  print sys.argv
	
  if len(sys.argv) >=2 :
    input_file = sys.argv[1]
    
    if os.path.isfile(input_file):
      output_file = os.path.splitext(input_file)[0] + '_half' + os.path.splitext(input_file)[1]
      
      if not os.path.exists(output_file):
        to_run = ['convert', '-resize', '50%', input_file, output_file] 
        print 'Calling ', to_run
        subprocess.call(to_run)
  
  return 0

if __name__ == '__main__':
	main()

